
// myScript.js contains all my scripts
$(document).ready(function(){
    
    $("#province").focus();
    
    $("#data").load("data.php");
    $('#data').hide();
    
    
    $("#show_data").click(function(){
       $("#data").fadeIn();
       $("#form").fadeOut();
    });
    
    $("#test").truncate({
                length: 200,
                mintrail: 20,
                moreText: "see more...",
                lessText: "see less",
                ellipsisText: ""
    });
                  
    function validate(){
        var id, msg;
        if($("#province").val() == ""){
            id = '#province';
            msg = "Please enter your province.";
        }
        else if($("#city_municipality").val() == ""){
            id = '#city_municipality';
            msg = "Please enter your city/municipality.";
        }
        else if($("#first_name").val() == ""){
            id = '#first_name';
            msg = "Please enter your first name..";
        }
        else if($("#middle_name").val() == ""){
            id = '#middle_name';
            msg = "Please enter your middle name..";
        }
        else if($("#last_name").val() == ""){
            alert("Please enter last name.");
            $("#last_name").focus();
        }
        else if($("#hospital_street").val() == ""){
            alert("Please enter the name of Hospital/Institution you were born; if not in hospital, give street/barangay .");
            $("#hospital_street").focus();
        }
        else if($("#p_city_municipality").val() == ""){
            alert("Please enter city/municipality you were born.");
            $("#p_city_municipality").focus();
        }
        else if($("#p_province").val() == ""){
            alert("Please enter the province you were born.");
            $("#p_province").focus();
        }
        else if($("#m_first_name").val() == ""){
            alert("Please enter you mother's first name.");
            $("#m_first_name").focus();
        }
        else if($("#m_middle_name").val() == ""){
            alert("Please enter you mother's middle name.");
            $("#m_middle_name").focus();
        }
        else if($("#m_last_name").val() == ""){
            alert("Please enter you mother's last name.");
            $("#m_last_name").focus();
        }
        else if($("#m_nationality").val() == ""){
            alert("Please enter you mother's Nationality.");
            $("#m_nationality").focus();
        }
        else if($("#m_religion").val() == ""){
            alert("Please enter you mother's religion.");
            $("#m_religion").focus();
        }
        else if($("#f_first_name").val() == ""){
            alert("Please enter you father's first name.");
            $("#f_first_name").focus();
        }
        else if($("#f_middle_name").val() == ""){
            alert("Please enter you father's middle name.");
            $("#f_middle_name").focus();
        }
        else if($("#f_last_name").val() == ""){
            alert("Please enter you father's last name.");
            $("#f_last_name").focus();
        }
        else if($("#f_nationality").val() == ""){
            alert("Please enter you father's Nationality.");
            $("#f_nationality").focus();
        }
        else if($("#f_religion").val() == ""){
            alert("Please enter you father's religion.");
            $("#f_religion").focus();
        }
        else{
            msg = "Successful!";
            id = "#reg";
            $("#s").html('');
            $("#s").html('<img src="images/loader.gif" /><br />Requesting...');
            $("#form").ajaxForm({
            target: '#s'
            }).submit();
            $("#data").load("data.php");
        }

        $("#a").dialog({
        
            modal: true,
            
            buttons: {
                'OK' : function(){
                    $(this).dialog('close');
                    $(id).focus();
                }
            }
        
        });
    }
    
    $("#reg").click(function(){
        validate();    
    });
    
    
    $("#some").tabs({
                    animate: 'slide'
    });
    
     
    $(window).scroll(function() {
    
      var scrollYpos = $(document).scrollTop();
        
        if (scrollYpos > 150 ) {
    
          
          $('#left-panel').animate({'margin-top': scrollYpos - 150 }, {duration: 500, queue: false});
    
        } else {
          
          
          $('#left-panel').animate({'margin-top': 0 }, {duration: 500, queue: false});
        }
    });
//            $('#dt').datepicker({
//				inline: true,
//				//nextText: '&rarr;',
//				//prevText: '&larr;',
//				showOtherMonths: true,
//				//dateFormat: 'dd MM yy',
//				dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
//				//showOn: "button",
//				//buttonImage: "img/calendar-blue.png",
//				//buttonImageOnly: true,
//
    

});
